using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Resources;
using System.Drawing.Imaging;
using System.Drawing;
using System.Reflection;
using System.Globalization;


namespace PlayTime
{
    public enum CardType { TWO = 2, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING, ACE };
    public enum CardSuit { Clubs = 0, Diamonds, Heart, Spade };

    public class Card
    {
        private CardType m_eType;
        private CardSuit m_eSuit;
        public Card(CardSuit cs, CardType cr)
        {
            m_eType = cr;
            m_eSuit = cs;
        }
        public Card(string s)
        {
            string[] tok = s.Split('_');
            if (tok.Length == 2)
            {
                m_eType = getCardType(tok[0]);
                m_eSuit = getCardSuit(tok[1]);
            }
        }

        private CardSuit getCardSuit(string p)
        {
            CardSuit temp = CardSuit.Clubs;
            foreach (CardSuit cs in CardSuit.GetValues(typeof(CardSuit)))
            {
                if (cs.ToString() == p)
                {
                    temp = cs;
                    break;
                }
            }
            return temp;

        }
        //public static bool operator == (Card lhs, Card rhs)
        //{
        //    if ((lhs == null) && (rhs == null))
        //    {
        //        return true;
        //    }
        //    if ((lhs.m_eSuit == rhs.m_eSuit) && (lhs.m_eType == rhs.m_eType))
        //    {
        //        return true;
        //    }
        //    return false;
        //}
        //public static bool operator !=(Card lhs, Card rhs)
        //{
        //    if (lhs == rhs)
        //    {
        //        return false;
        //    }
            
        //        return true;
           
        //}
        private CardType getCardType(string p)
        {
            CardType temp = CardType.TWO;
            foreach (CardType ct in CardType.GetValues(typeof(CardType)))
            {
                if (ct.ToString() == p)
                {
                    temp = ct;
                    break;
                }
            }
            return temp;

        }

        public CardType CardType
        {
            get { return m_eType; }
        }

        public CardSuit CardSuit
        {
            get { return m_eSuit; }
        }

        public string GetImageName()
        {
            return GetSymbolText();
        }

        public string GetSymbolText()
        {
            return m_eType.ToString() + "_" + m_eSuit.ToString();
        }

    };


    //	A shared reference to access images and other resources.
    internal abstract class Resources
    {
        private static ResourceManager imgMgnr;

        static Resources()
        {
            imgMgnr = new ResourceManager("PlayTime.Properties.Resources", Assembly.GetExecutingAssembly());
        }

        public static ResourceManager Images
        {
            get { return imgMgnr; }
        }

        public static Image GetImage(string imageId)
        {
            return (Image)imgMgnr.GetObject(imageId, CultureInfo.InvariantCulture);
        }
    }
}
